package com.java.java8.util.functioninterfacedemo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BinaryOperator;

/**
 * @author liyanhao
 * @Date 2023-03-27 9:16
 */
public class BinaryOperatorDemo {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("X", "A");
        map.put("Y", "B");
        map.put("Z", "C");
        BinaryOperator<String> binaryOperator = (s1, s2) -> s1 + "_" + s2;
        System.out.println(binaryOperatorFun(binaryOperator, map));
    }


    private static List<String> binaryOperatorFun(BinaryOperator<String> binaryOperator, Map<String, String> map) {
        ArrayList<String> strings = new ArrayList<>();
        map.forEach((v, k) -> strings.add(binaryOperator.apply(v, k)));
        return strings;
    }

}
